/*
 * Copyright 2007 Xplayat, S.L. All rights reserved.
 * Propiedad de Xplayat. 
 */
package org.apache.myfaces.custom.ysf.document;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import org.apache.myfaces.custom.document.AbstractDocument;


/**
 * 
 * @author Nacho Estrada <nacho.estrada -at- xplayat.es> (website http://www.xplayat.es)
 *
 */
public class DocumentRenderer extends org.apache.myfaces.custom.document.DocumentRenderer {
	
	public void encodeBegin(FacesContext facesContext, UIComponent uiComponent)
			throws IOException {
		ResponseWriter writer = facesContext.getResponseWriter();
		
		writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " +
					"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
		super.encodeBegin(facesContext, uiComponent);
		AbstractDocument document = (AbstractDocument) uiComponent;
		if (!document.hasState() || !document.isEndState())
			writer.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml", null);		
	}
	
}
	


